package com.kitty.web.controller;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.mail.model.Mail;
import com.kitty.game.pet.model.Pet;
import com.kitty.game.pet.model.PetBox;
import com.kitty.game.role.model.Role;
import com.kitty.game.role.service.RoleService;
import com.kitty.game.utils.Const;
import com.kitty.game.utils.JsonUtils;
import com.kitty.game.utils.TimeUtil;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.domain.ClearDaoVo;
import com.kitty.web.domain.TRole;
import com.kitty.web.system.gameServer.GameServerRefresh;
import com.kitty.web.system.send.domain.*;
import com.kitty.web.system.send.service.SendService;
import org.nutz.lang.util.NutMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/system/cacheManage")
public class CacheManage {
    @Autowired
    GameServerRefresh gameServerRefresh;
    @Autowired
    SendService sendService;


    private String prefix = "system/send";


    @GetMapping()
    public String send()
    {
        return prefix + "/sendReward";
    }



    @PostMapping("/refreshCache")
    @ResponseBody
    public AjaxResult list(String  type, String value, String state){
        return gameServerRefresh.refreshCache(type,value,state);
    }
    /**
     * 发送【称谓】
     */
    @PostMapping("/send_title")
    @ResponseBody
    public AjaxResult title(SendTitle title)
    {
        return sendService.title(title);
    }

    /**
     * 发送【宠物/坐骑】
     */
    @PostMapping("/send_pet")
    @ResponseBody
    public AjaxResult pet(SendPet pet)
    {
        return sendService.pet(pet);
    }
    /**
     * 发送【元宝、积分、抽奖次数】
     */
    @PostMapping("/send_coin")
    @ResponseBody
    public AjaxResult coin(SendCoin coin)
    {
        return sendService.coin(coin);
    }
    /**
     * 发送【法宝】
     */
    @PostMapping("/send_magicWeapon")
    @ResponseBody
    public AjaxResult magicWeapon(SendMagicWeapon magicWeapon)
    {
        return sendService.magicWeapon(magicWeapon);
    }

    /**
     * 发送【道具】
     */
    @PostMapping("/send_item")
    @ResponseBody
    public AjaxResult item(SendItem sendItem)
    {
        return sendService.sendItem(sendItem);
    }

    /**
     * 发送【道具】
     */
    @PostMapping("/send_money")
    @ResponseBody
    public AjaxResult money(SendMoney sendMoney)
    {
        return sendService.sendmoney(sendMoney);
    }

    /**
     * 发送【公告】
     */
    @PostMapping("/send_notice")
    @ResponseBody
    public AjaxResult notice(SendNotice sendNotice)
    {
        return sendService.sendNotice(sendNotice);
    }

    /**
     * 发送【装备】
     */
    @PostMapping("/send_equipment")
    @ResponseBody
    public AjaxResult equipment(SendEquipment equipment)
    {
        return sendService.equipment(equipment);
    }

    /**
     * 发送【首饰】
     */
    @PostMapping("/send_ornaments")
    @ResponseBody
    public AjaxResult ornaments(SendOrnaments ornaments)
    {
        return sendService.ornaments(ornaments);
    }


    /**
     * 清除角色道行
     */
    @PostMapping("/clearRoleDao")
    @ResponseBody
    public AjaxResult clearRoleDao(ClearDaoVo clearDaoVo){
        AjaxResult ajaxResult = SpringUtils.getBean(TRoleController.class).clearRoleDao(clearDaoVo);
        return ajaxResult;
    }
    /**
     * 清除宠物武学
     */
    @PostMapping("/clearPetWu")
    @ResponseBody
    public AjaxResult clearPetWu(ClearDaoVo clearDaoVo){
        AjaxResult ajaxResult = SpringUtils.getBean(TRoleController.class).clearPetWu(clearDaoVo);
        return ajaxResult;
    }

    @PostMapping("/rebootTask")
    @ResponseBody
    public AjaxResult rebootTask(){
        AjaxResult ajaxResult = SpringUtils.getBean(RoleService.class).doDailyFiveResetForAll();
        return ajaxResult;
    }
}
